//
//  WMEUserCollectionViewCell.m
//  everyDay_duiTang
//
//  Created by 恩叔 on 16/1/23.
//  Copyright © 2016年 enshu. All rights reserved.
//

#import "WMEUserCollectionViewCell.h"
#import <UIImageView+WebCache.h>
#pragma mark - 用户界面的collection的cell
@interface WMEUserCollectionViewCell ()
@property (nonatomic, retain)UIImageView *contentImage;
@end
//static CGFloat g = 0;
@implementation WMEUserCollectionViewCell
- (void)dealloc
{
    [_contentImage release];
    [_model release];
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.contentImage = [[UIImageView alloc] init];
        _contentImage.backgroundColor = [UIColor lightGrayColor];
        [self.contentView addSubview:_contentImage];
        [_contentImage release];
    }
    return self;
}

- (void)setModel:(WMEUserModel *)model
{
    if (_model != model) {
        [_model release];
        _model = [model retain];
        NSLog(@"%@", _model);
        [_contentImage sd_setImageWithURL:[NSURL URLWithString:[_model.path stringByReplacingOccurrencesOfString:@"_webp" withString:@""]]];
    }
}

- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes
{
    _contentImage.frame = layoutAttributes.bounds;
    _contentImage.contentMode = UIViewContentModeScaleAspectFill;
    _contentImage.clipsToBounds = YES;
//    g = g + layoutAttributes.bounds.size.height;
//    NSLog(@"%lf",layoutAttributes.bounds.size.height);
}

@end
